package com.example.index.controller;

import com.example.index.entity.Teacher;
import com.example.index.entity.User;
import com.example.index.service.TeacherService;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;

import javax.annotation.Resource;
import java.util.List;

@Controller
public class TeacherController {

    /**
     * 服务对象
     */
    @Resource
    private TeacherService teacherService;

    @GetMapping("teacher")
    public String teacher(ModelMap modelMap) {
        Page<Teacher> teachers = teacherService.queryByPage(new Teacher(), PageRequest.of(0, 100));
        List<Teacher> TeachersList = teachers.getContent();
        System.out.println(TeachersList);
        modelMap.addAttribute("teachersList",TeachersList);
        return "teacher";
    }
}
